<!DOCTYPE html>
<html>

	<head lang="en">
		<title>首页</title>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
		<script src="/js/jquery/jquery.min.js"></script>
		<script src="/js/bootstrap/js/bootstrap.min.js"></script>
		<link rel="stylesheet" href="/css/font/css/font-awesome.min.css" />
		<link rel="stylesheet" href="/css/reset.css" />
		<link rel="stylesheet" href="/css/strategyDetails.css" />
		<script src="/js/plugins/jrender/jrender.min.js"></script>
		<script src="/js/common.js"></script>
		<script src="/js/plugins/dialog2/dialog.min.js"></script>
		<link rel="stylesheet" href="/js/plugins/dialog2/dialog.css">
		<script>
			$(function () {
				var params = getParams();
				var countstr = sessionStorage.getItem("cartNum");
				if(countstr){
                    var count = JSON.parse(countstr);
				}
                var userStr = sessionStorage.getItem("user");
                var userId;
                //商品积分
                var myIntegral=0;
                if (userStr) {
                    userId = JSON.parse(userStr).id;
                    $.get("/integral/"+userId,function (data) {
                        if(data){
                            var integral="我的积分: "
                            myIntegral = data.count
                            $("#myIntegral").after(integral+myIntegral)
                        }
                    })
                }
				if(params.id){
				    $.get("/product/"+params.id,function (data) {
                        $(".detail").renderValues(data,{
                            setHref:setHref()
						});
                    },"json");
                    //加入购物车 saveBtn
                    $(".saveBtn").click(function () {
                        $.post("/product",{'id':params.id},function (data) {
                            if(data.success){
                                //回显购物车数据
                                count = data.data.length
                                sessionStorage.setItem("cartNum", JSON.stringify(count));
                                $(document).dialog({
                                    type : 'toast',
                                    infoIcon: '../img/icon/success.png',
                                    infoText: '成功',
                                    autoClose: 1000
                                });
                            }else{
                                $(document).dialog({
                                    type : 'confirm',
                                    closeBtnShow: true,
                                    content: data.msg,
                                    onClickConfirmBtn: function(){
                                        window.location.href="/mine/shoppingcart.html"
                                    }
                                });
                            }
                        })
                    });
				}
            })
		</script>
	</head>
	<body>
	<div class=" nav-search">
		<a href="javascript:history.go(-1);">
			<span><i class="fa fa-chevron-left"></i></span>
		</a>
	</div>
	<hr>

	<div class="container detail">
		<h4 class="name"><strong render-html="name"></strong></h4>
		<img class="head-img" render-src="img">
		<p render-html="productType.name">系列: </p>
		<div class="content" render-html="intro">
		</div>
			<p>兑换积分:<span render-html="salePrice"></span> &nbsp;&nbsp;&nbsp;<span><button type="button" class="btn btn-danger btn-sm saveBtn">加入购物车</button></span></p>
	</div>
	<hr>
	</body>
</html>